﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Interview_Easy_0304_MyQueue
{
    class MainProject
    {
        static void Main(string[] args)
        {
            //Console.WriteLine(TimeRequiredToBuy(new int[] { 84, 49, 5, 24, 70, 77, 87, 8 }, 3));
            Console.ReadKey();
        }
    }
    public class MyQueue
    {
        private Stack<int> m_Stack_1 = new Stack<int>();
        private Stack<int> m_Stack_2 = new Stack<int>();
        /** Initialize your data structure here. */
        public MyQueue()
        {

        }

        /** Push element x to the back of queue. */
        public void Push(int x)
        {
            m_Stack_1.Push(x);
        }

        /** Removes the element from in front of queue and returns that element. */
        public int Pop()
        {
            if (m_Stack_1.Count > 0)
            {
                m_Stack_2.Clear();
                foreach (var item in m_Stack_1) m_Stack_2.Push(item);
                int res = m_Stack_2.Pop();
                m_Stack_1.Clear();
                foreach (var item in m_Stack_2) m_Stack_1.Push(item);
                return res;
            }
            else return 0;
        }

        /** Get the front element. */
        public int Peek()
        {
            if (m_Stack_1.Count > 0)
            {
                m_Stack_2.Clear();
                foreach (var item in m_Stack_1) m_Stack_2.Push(item);
                return m_Stack_2.Peek();
            }
            else return 0;
        }

        /** Returns whether the queue is empty. */
        public bool Empty()
        {
            return m_Stack_1.Count == 0 ? true : false;
        }
    }
}
